/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aedustuff;

import javax.swing.JButton;

/**
 *
 * @author ibm
 */
public class Gui extends javax.swing.JFrame {

    MainCardDeck mainCardDeck;
    GameFieldCardDeck cardDeck0;
    GameFieldCardDeck cardDeck1;
    GameFieldCardDeck cardDeck2;
    GameFieldCardDeck cardDeck3;
    Player player;
    JButton[][] buttons;

    /**
     * Creates new form Gui
     */
    public Gui() {
        mainCardDeck = new MainCardDeck();
        cardDeck0 = new GameFieldCardDeck();
        cardDeck1 = new GameFieldCardDeck();
        cardDeck2 = new GameFieldCardDeck();
        cardDeck3 = new GameFieldCardDeck();
        player = new Player("Sebo");
        buttons = new JButton[4][3];
        initComponents();
        mainCardDeckUpperCard.setContentAreaFilled(false);
        updatePlayerStats();
        assignButtons();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        row30Button = new javax.swing.JButton();
        row32Button = new javax.swing.JButton();
        row31Button = new javax.swing.JButton();
        row21Button = new javax.swing.JButton();
        row20Button = new javax.swing.JButton();
        row10Button = new javax.swing.JButton();
        row22Button = new javax.swing.JButton();
        row12Button = new javax.swing.JButton();
        row11Button = new javax.swing.JButton();
        getRow2Button = new javax.swing.JButton();
        getRow1Button = new javax.swing.JButton();
        getRow3Button = new javax.swing.JButton();
        brownCountButton = new javax.swing.JButton();
        greenCountButton = new javax.swing.JButton();
        blueCountButton = new javax.swing.JButton();
        greyCountButton = new javax.swing.JButton();
        orangeCountButton = new javax.swing.JButton();
        rosaCountButton = new javax.swing.JButton();
        yellowCountButton = new javax.swing.JButton();
        mainCardDeckUpperCard = new javax.swing.JButton();
        mainCardDeckButton = new javax.swing.JButton();
        row02Button = new javax.swing.JButton();
        getRow0Button = new javax.swing.JButton();
        row01Button = new javax.swing.JButton();
        row00Button = new javax.swing.JButton();
        blueCountLabel = new javax.swing.JLabel();
        brownCountLabel = new javax.swing.JLabel();
        greenCountLabel = new javax.swing.JLabel();
        greyCountLabel = new javax.swing.JLabel();
        orangeCountLabel = new javax.swing.JLabel();
        rosaCountLabel = new javax.swing.JLabel();
        yellowCountLabel = new javax.swing.JLabel();
        playerPointsTextLabel = new javax.swing.JLabel();
        playerPointsValueLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        row30Button.setEnabled(false);
        row30Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row30ButtonActionPerformed(evt);
            }
        });

        row32Button.setEnabled(false);
        row32Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row32ButtonActionPerformed(evt);
            }
        });

        row31Button.setEnabled(false);
        row31Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row31ButtonActionPerformed(evt);
            }
        });

        row21Button.setEnabled(false);
        row21Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row21ButtonActionPerformed(evt);
            }
        });

        row20Button.setEnabled(false);
        row20Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row20ButtonActionPerformed(evt);
            }
        });

        row10Button.setEnabled(false);
        row10Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row10ButtonActionPerformed(evt);
            }
        });

        row22Button.setEnabled(false);
        row22Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row22ButtonActionPerformed(evt);
            }
        });

        row12Button.setEnabled(false);
        row12Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row12ButtonActionPerformed(evt);
            }
        });

        row11Button.setEnabled(false);
        row11Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row11ButtonActionPerformed(evt);
            }
        });

        getRow2Button.setText("get ->");
        getRow2Button.setEnabled(false);
        getRow2Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getRow2ButtonActionPerformed(evt);
            }
        });

        getRow1Button.setText("get ->");
        getRow1Button.setEnabled(false);
        getRow1Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getRow1ButtonActionPerformed(evt);
            }
        });

        getRow3Button.setText("get ->");
        getRow3Button.setEnabled(false);
        getRow3Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getRow3ButtonActionPerformed(evt);
            }
        });

        brownCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/brown.jpg"))); // NOI18N

        greenCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/green.jpg"))); // NOI18N

        blueCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/blue.jpg"))); // NOI18N

        greyCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/grey.jpg"))); // NOI18N

        orangeCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/orange.jpg"))); // NOI18N

        rosaCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/rosa.jpg"))); // NOI18N

        yellowCountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/yellow.jpg"))); // NOI18N

        mainCardDeckUpperCard.setEnabled(false);

        mainCardDeckButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/back.jpg"))); // NOI18N
        mainCardDeckButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mainCardDeckButtonActionPerformed(evt);
            }
        });

        row02Button.setEnabled(false);
        row02Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row02ButtonActionPerformed(evt);
            }
        });

        getRow0Button.setText("get ->");
        getRow0Button.setEnabled(false);
        getRow0Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getRow0ButtonActionPerformed(evt);
            }
        });

        row01Button.setEnabled(false);
        row01Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row01ButtonActionPerformed(evt);
            }
        });

        row00Button.setEnabled(false);
        row00Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                row00ButtonActionPerformed(evt);
            }
        });

        blueCountLabel.setText("0");

        brownCountLabel.setText("0");

        greenCountLabel.setText("0");

        greyCountLabel.setText("0");

        orangeCountLabel.setText("0");

        rosaCountLabel.setText("0");

        yellowCountLabel.setText("0");

        playerPointsTextLabel.setText("Gesamt:");

        playerPointsValueLabel.setText("0");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(mainCardDeckButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(blueCountLabel)
                                .addGap(78, 78, 78)
                                .addComponent(brownCountLabel))
                            .addComponent(mainCardDeckUpperCard, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(getRow0Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(33, 33, 33)
                                        .addComponent(row00Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(row01Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(row02Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(getRow1Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(getRow2Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(getRow3Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup()
                                                    .addComponent(row20Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(row21Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(row22Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(layout.createSequentialGroup()
                                                    .addComponent(row10Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(row11Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(row12Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                    .addComponent(greyCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(row30Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(row31Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(row32Button, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(63, 63, 63)
                                .addComponent(greenCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(rosaCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(53, 53, 53)))
                        .addComponent(yellowCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(playerPointsTextLabel)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(orangeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(blueCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(12, 12, 12)
                                        .addComponent(brownCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(greenCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(greyCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(orangeCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(rosaCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(yellowCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(playerPointsValueLabel))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(80, 80, 80)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(mainCardDeckButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mainCardDeckUpperCard, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(getRow0Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row02Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row01Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row00Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(row12Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row11Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row10Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(getRow1Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(row22Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row21Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row20Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(row32Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row31Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(row30Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(getRow2Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(getRow3Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(playerPointsTextLabel)
                    .addComponent(playerPointsValueLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(blueCountLabel)
                    .addComponent(brownCountLabel)
                    .addComponent(greenCountLabel)
                    .addComponent(greyCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(orangeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rosaCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(yellowCountLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(brownCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(greenCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(blueCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(greyCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(orangeCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rosaCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(yellowCountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mainCardDeckButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainCardDeckButtonActionPerformed
        deactivateAllGetRowButtons();
        changeColorFromCard(mainCardDeckUpperCard, mainCardDeck.getColorFromTopCard());
        setGameFieldForCardPlacement();
    }//GEN-LAST:event_mainCardDeckButtonActionPerformed

    private void row00ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row00ButtonActionPerformed
        changeColorFromCard(row00Button, mainCardDeck.getColorFromTopCard());
        cardDeck0.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row00ButtonActionPerformed

    private void row01ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row01ButtonActionPerformed
        changeColorFromCard(row01Button, mainCardDeck.getColorFromTopCard());
        cardDeck0.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row01ButtonActionPerformed

    private void row02ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row02ButtonActionPerformed
        changeColorFromCard(row02Button, mainCardDeck.getColorFromTopCard());
        cardDeck0.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row02ButtonActionPerformed

    private void row10ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row10ButtonActionPerformed
        changeColorFromCard(row10Button, mainCardDeck.getColorFromTopCard());
        cardDeck1.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row10ButtonActionPerformed

    private void row11ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row11ButtonActionPerformed
        changeColorFromCard(row11Button, mainCardDeck.getColorFromTopCard());
        cardDeck1.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row11ButtonActionPerformed

    private void row12ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row12ButtonActionPerformed
        changeColorFromCard(row12Button, mainCardDeck.getColorFromTopCard());
        cardDeck1.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row12ButtonActionPerformed

    private void row20ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row20ButtonActionPerformed
        changeColorFromCard(row20Button, mainCardDeck.getColorFromTopCard());
        cardDeck2.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row20ButtonActionPerformed

    private void row21ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row21ButtonActionPerformed
        changeColorFromCard(row21Button, mainCardDeck.getColorFromTopCard());
        cardDeck2.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row21ButtonActionPerformed

    private void row22ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row22ButtonActionPerformed
        changeColorFromCard(row22Button, mainCardDeck.getColorFromTopCard());
        cardDeck2.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row22ButtonActionPerformed

    private void row30ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row30ButtonActionPerformed
        changeColorFromCard(row30Button, mainCardDeck.getColorFromTopCard());
        cardDeck3.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row30ButtonActionPerformed

    private void row31ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row31ButtonActionPerformed
        changeColorFromCard(row31Button, mainCardDeck.getColorFromTopCard());
        cardDeck3.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row31ButtonActionPerformed

    private void row32ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_row32ButtonActionPerformed
        changeColorFromCard(row32Button, mainCardDeck.getColorFromTopCard());
        cardDeck3.addCardFrom(mainCardDeck);
        setGameFieldForBothOptions();
    }//GEN-LAST:event_row32ButtonActionPerformed

    private void getRow0ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getRow0ButtonActionPerformed
        player.takeUpCards(cardDeck0.getCards());
        emptyButtonIconsOfRow(0);
        getRow0Button.setEnabled(false);
        setGameFieldForBothOptions();
        updatePlayerStats();
    }//GEN-LAST:event_getRow0ButtonActionPerformed

    private void getRow1ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getRow1ButtonActionPerformed
        player.takeUpCards(cardDeck1.getCards());
        emptyButtonIconsOfRow(1);
        getRow1Button.setEnabled(false);
        setGameFieldForBothOptions();
        updatePlayerStats();
    }//GEN-LAST:event_getRow1ButtonActionPerformed

    private void getRow2ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getRow2ButtonActionPerformed
        player.takeUpCards(cardDeck2.getCards());
        emptyButtonIconsOfRow(2);
        getRow2Button.setEnabled(false);
        setGameFieldForBothOptions();
        updatePlayerStats();
    }//GEN-LAST:event_getRow2ButtonActionPerformed

    private void getRow3ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getRow3ButtonActionPerformed
        player.takeUpCards(cardDeck3.getCards());
        emptyButtonIconsOfRow(3);
        getRow3Button.setEnabled(false);
        setGameFieldForBothOptions();
        updatePlayerStats();
    }//GEN-LAST:event_getRow3ButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Gui().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton blueCountButton;
    private javax.swing.JLabel blueCountLabel;
    private javax.swing.JButton brownCountButton;
    private javax.swing.JLabel brownCountLabel;
    private javax.swing.JButton getRow0Button;
    private javax.swing.JButton getRow1Button;
    private javax.swing.JButton getRow2Button;
    private javax.swing.JButton getRow3Button;
    private javax.swing.JButton greenCountButton;
    private javax.swing.JLabel greenCountLabel;
    private javax.swing.JButton greyCountButton;
    private javax.swing.JLabel greyCountLabel;
    private javax.swing.JButton mainCardDeckButton;
    private javax.swing.JButton mainCardDeckUpperCard;
    private javax.swing.JButton orangeCountButton;
    private javax.swing.JLabel orangeCountLabel;
    private javax.swing.JLabel playerPointsTextLabel;
    private javax.swing.JLabel playerPointsValueLabel;
    private javax.swing.JButton rosaCountButton;
    private javax.swing.JLabel rosaCountLabel;
    private javax.swing.JButton row00Button;
    private javax.swing.JButton row01Button;
    private javax.swing.JButton row02Button;
    private javax.swing.JButton row10Button;
    private javax.swing.JButton row11Button;
    private javax.swing.JButton row12Button;
    private javax.swing.JButton row20Button;
    private javax.swing.JButton row21Button;
    private javax.swing.JButton row22Button;
    private javax.swing.JButton row30Button;
    private javax.swing.JButton row31Button;
    private javax.swing.JButton row32Button;
    private javax.swing.JButton yellowCountButton;
    private javax.swing.JLabel yellowCountLabel;
    // End of variables declaration//GEN-END:variables

    private void changeColorFromCard(JButton button, CardColor color) {
        String picName = "";
        switch (color) {
            case BLAU:
                picName = "blue";
                break;
            case BRAUN:
                picName = "brown";
                break;
            case GRUEN:
                picName = "green";
                break;
            case GRAU:
                picName = "grey";
                break;
            case ORANGE:
                picName = "orange";
                break;
            case ROSA:
                picName = "rosa";
                break;
            case GELB:
                picName = "yellow";
                break;
        }
        if (!button.isEnabled()) {
            button.setEnabled(true);
        }
        button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cards/resources/pictures/" + picName + ".jpg"))); // NOI18N
    }

    private void setGameFieldForCardPlacement() {
        if (!cardDeck0.isFull()) {
            buttons[0][cardDeck0.cardCount()].setEnabled(true);
        }
        if (!cardDeck1.isFull()) {
            buttons[1][cardDeck1.cardCount()].setEnabled(true);
        }
        if (!cardDeck2.isFull()) {
            buttons[2][cardDeck2.cardCount()].setEnabled(true);
        }
        if (!cardDeck3.isFull()) {
            buttons[3][cardDeck3.cardCount()].setEnabled(true);
        }
        mainCardDeckButton.setEnabled(false);
    }

    private void setGameFieldForBothOptions() {
        mainCardDeckUpperCard.setIcon(null);
        deactivateAllGameFieldButtons();
        activateGetRowButtons();
        if (!(mainCardDeck.isEmpty()||allGameFieldsAreFull())) {
            mainCardDeckButton.setEnabled(true);
        }
    }

    private void deactivateAllGameFieldButtons() {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                buttons[i][j].setEnabled(false);
                buttons[i][j].setDisabledIcon(buttons[i][j].getIcon());
            }
        }
    }

    private void activateGetRowButtons() {
        if (!cardDeck0.isEmpty()) {
            getRow0Button.setEnabled(true);
        }
        if (!cardDeck1.isEmpty()) {
            getRow1Button.setEnabled(true);
        }
        if (!cardDeck2.isEmpty()) {
            getRow2Button.setEnabled(true);
        }
        if (!cardDeck3.isEmpty()) {
            getRow3Button.setEnabled(true);
        }
    }

    private void assignButtons() {
        buttons[0][0] = row00Button;
        buttons[0][1] = row01Button;
        buttons[0][2] = row02Button;
        buttons[1][0] = row10Button;
        buttons[1][1] = row11Button;
        buttons[1][2] = row12Button;
        buttons[2][0] = row20Button;
        buttons[2][1] = row21Button;
        buttons[2][2] = row22Button;
        buttons[3][0] = row30Button;
        buttons[3][1] = row31Button;
        buttons[3][2] = row32Button;
    }

    private void deactivateAllGetRowButtons() {
        getRow0Button.setEnabled(false);
        getRow1Button.setEnabled(false);
        getRow2Button.setEnabled(false);
        getRow3Button.setEnabled(false);
    }

    private void updatePlayerStats() {
        for (CardColor cardColor : CardColor.values()) {
            int colorScore = player.getAmountOfCardColor(cardColor);
            switch (cardColor) {
                case BLAU:
                    blueCountLabel.setText(String.valueOf(colorScore));
                    break;
                case ORANGE:
                    orangeCountLabel.setText(String.valueOf(colorScore));
                    break;
                case BRAUN:
                    brownCountLabel.setText(String.valueOf(colorScore));
                    break;
                case GRUEN:
                    greenCountLabel.setText(String.valueOf(colorScore));
                    break;
                case GRAU:
                    greyCountLabel.setText(String.valueOf(colorScore));
                    break;
                case ROSA:
                    rosaCountLabel.setText(String.valueOf(colorScore));
                    break;
                case GELB:
                    yellowCountLabel.setText(String.valueOf(colorScore));
                    break;
            }
        }
        playerPointsValueLabel.setText(String.valueOf(player.getTotalScore()));
    }

    private void emptyButtonIconsOfRow(int i) {
        buttons[i][0].setIcon(null);
        buttons[i][1].setIcon(null);
        buttons[i][2].setIcon(null);
    }

    private boolean allGameFieldsAreFull() {
        if(cardDeck0.isFull()&&cardDeck1.isFull()&&cardDeck2.isFull()&&cardDeck3.isFull()){
            return true;
        }else{
            return false;
        }
    }
}
